﻿using UnityEngine;

namespace UFrame
{
    /// <summary>
    /// 几何随机
    /// </summary>
    public static class GeometryRandomTool
    {
        /// <summary>
        /// 随机不在圆内
        /// </summary>
        public static Vector2 OutSideCircle2D(float radio, Vector2 origin)
        {
            Vector2 v = new Vector2(Random.Range(-radio, radio), Random.Range(-radio, radio));

            var dir = v - origin;
            var dis = Vector2.Distance(origin, v);
            v += dir.normalized * Random.Range(radio - dis, radio);
            return v;
        }
    }
}